package test2;

public class StartPhone {
    public static void main(String[] args) {
        //创建三部手机对象
        Phone phone1 = new Phone("小米","14 Pro","岩石青",4299);
        Phone phone2 = new Phone("REDMI","K80","雪岩白",2499);
        Phone phone3 = new Phone("华为","Mate 70 pro+","墨韵黑",8499);

        //创建数组存放三台手机信息
        Phone[] calculate=new Phone[3];
        calculate[0]=phone1;
        calculate[1]=phone2;
        calculate[2]=phone3;

        //计算平均价格
        double result=0;
        for(int i=0; i<calculate.length; i++){
            result+=calculate[i].getPrice();
        }
        result/=calculate.length;

        //输出结果
        System.out.printf("平均价格为 %4.2f 元\n",result);
    }

}
